package com.mfangsoft.zhuangjialong.app.customer.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mfangsoft.zhuangjialong.app.customer.mapper.CustomerMapper;
import com.mfangsoft.zhuangjialong.app.customer.service.ICustomerService;
import com.mfangsoft.zhuangjialong.common.model.Page;

@Service("appCustomerService")
public class CustomerServiceImpl implements ICustomerService {

	@Autowired
	CustomerMapper customerMapper;
	
	@Override
	public Page<Map<String, Object>> selectSellerCustomer(Page<Map<String, Object>> page) {
		List<Map<String,Object>> sellerCustomer = customerMapper.selectSellerCustomerPage(page);
		page.setData(sellerCustomer);
		return page;
	}

	@Override
	public Map<String, Object> selectSellerCustomerDetail(Map<String, Object> map) {
		Map<String,Object> detail=new HashMap<String, Object>();
		Map<String, Object> customerInfo = customerMapper.selectCustomerInfo(map);
//		String customerAddress = customerMapper.selectCustomerAddress(map);
//		customerInfo.put("consignee_address", customerAddress);
		Integer gouTongStatus = customerMapper.selectGouTongStatus(map);
		customerInfo.put("communicationStatus", gouTongStatus);
		List<Map<String,Object>> customerActivity = customerMapper.selectCustomerActivity(map);
		List<Map<String,Object>> customerOrder = customerMapper.selectCustomerOrder(map);
		List<Map<String,Object>> customerCommunication = customerMapper.selectCustomerCommunication(map);
		List<Map<String,Object>> customerEvaluate = customerMapper.selectCustomerEvaluate(map);
		detail.put("customerInfo", customerInfo);
		detail.put("customerActivity", customerActivity);
		detail.put("customerOrder", customerOrder);
		detail.put("customerCommunication", customerCommunication);
		detail.put("customerEvaluate", customerEvaluate);
		return detail;
	}

	@Override
	public Page<Map<String, Object>> selectCustomerDataPage(Page<Map<String, Object>> page) {
		List<Map<String,Object>> sellerCustomer = customerMapper.selectCustomerPage(page);
		page.setData(sellerCustomer);
		return page;
	}
	@Override
	public List<Map<String,Object>> selectCustomer1DataPage( Long size) {
		List<Map<String,Object>> sellerCustomer = customerMapper.selectCustomer1(size);
		if(sellerCustomer !=null && !sellerCustomer.isEmpty()){
			customerMapper.updateCustomerIsPost(sellerCustomer);
		}
		return sellerCustomer;
	}

}
